﻿namespace ClientProxies
{
  using Common.Contracts;
  using ClientProxies.ArchiveServiceReference;
  using ClientProxies.OneStepServiceReference;

  public class ServiceFactory : IServiceFactory
  {
    //private IContainer _container;
    private readonly IServiceConfig _serviceConfig;

    public ServiceFactory(IServiceConfig serviceConfig)
    {
      this._serviceConfig = serviceConfig;
    }

    IFileService IServiceFactory.CreateFileServiceClient<T>()
    {

      if (_serviceConfig.IsFakeService() && typeof(T).Name == "IFileService")
      {
        return new FakeFileServiceClient();
      }
      else
      {
        return new FileServiceClient();
      }
    }

    IDocument IServiceFactory.CreateDocumentServiceClient<T>()
    {
      if (_serviceConfig.IsFakeService() && typeof(T).Name == "IDocument")
      {
        return new FakeDocumentClient(_serviceConfig);
      }
      else
      {
        return new DocumentClient();
      }
    }
  }
}
